package com.appspot.algroupselect;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

@SuppressWarnings("serial")
public class GSGroupServlet extends HttpServlet {

	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		
		Gson gson = new Gson();
		List<Map<String, String>> ret = new ArrayList<Map<String, String>>();

		for (int i = 1; i < 9; i ++) {
			HashMap<String, String> jsonMap = new HashMap<String, String>();
			jsonMap.put("id", "gid" + i);
			jsonMap.put("name", "gname" + i);
			ret.add(jsonMap);
		}
		
		resp.setContentType("application/json;charset=utf-8"); 
		resp.setHeader("Cache-Control", "no-cache");
		resp.getWriter().write(gson.toJson(ret));
	}

	
}
